﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.OleDb;

namespace Book
{
    public partial class Form2 : Form
    {
        public Form2()
        {
            InitializeComponent();
        }

        private void 注册_Click(object sender, EventArgs e)
        {
            OleDbConnection DBconnect = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\zAllstation\access\bookmanage.accdb");
            DBconnect.Open();
            if (textBox3.Text == textBox4.Text)
            {
                string sqlcmd = string.Format("insert into [reader](读者编号,姓名,密码) values('{0}','{1}','{2}') ", textBox1.Text, textBox2.Text, textBox3.Text);
                DataTable dtable = new DataTable();
                OleDbDataAdapter adt = new OleDbDataAdapter(sqlcmd, DBconnect);
                adt.Fill(dtable);
                MessageBox.Show("恭喜" + textBox2.Text + "注册完成!请返回首页进行登录！");
                Form1 form1 = new Form1();
                form1.Show();
                this.Hide();
            }
            else
            {
                textBox3.Text = "";
                textBox4.Text = "";
                MessageBox.Show("两次输入的密码不一样，请重新输入");
            }
        }

        private void label2_Click(object sender, EventArgs e)
        {

        }

        private void 取消_Click(object sender, EventArgs e)
        {
            Form1 form1 = new Form1();
            form1.Show();
            this.Hide();
        }

       
    }
}
